package cn.z2huo.demo.hello.kafka.api;

import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.concurrent.Future;

/**
 * <p>
 *
 * @author z2huo
 */
public interface KafkaOperations {

    /**
     * 向 Kafka 异步发送消息，
     * @param producerName
     * @param record
     * @param callback
     */
    void send(String producerName, ProducerRecord<String, String> record, Callback callback);

    Future<RecordMetadata> send(String producerName, ProducerRecord<String, String> record);

    /**
     * 对 Kafka 特定 topic 集合的消息订阅
     * @param consumerName  消费者名称
     * @param subscriber    订阅者
     */
    void subscribe(String consumerName, KafkaSubscriber subscriber);

}
